package controllers

import (
	"app_log_server/app/utils"
	"app_log_server/http/services"
	"log"
	"strconv"

	"github.com/gin-gonic/gin"
)

func GetProjectList(ctx *gin.Context) {
	page_index := ctx.DefaultQuery("page_index", "1")
	page_index_int, err := strconv.Atoi(page_index)
	if err != nil {
		utils.JSONError(ctx, 201, "page_index is not a number")
		return
	}
	data, err := services.GetProjectList(uint(page_index_int))
	if err != nil {
		log.Fatal(err)
		utils.JSONError(ctx, 202, "get project list failed")
		return
	}
	utils.JSONOk(ctx, data)
}
